package com.mentaleye.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.mentaleye.dal.dao.StudentInterviewRecordDao;
import com.mentaleye.dal.model.StudentInterviewRecord;
import com.mentaleye.dal.model.StudentInterviewRecordExample;
import com.mentaleye.dal.model.StudentInterviewRecordExample.Criteria;
import com.mentaleye.service.StudentInterviewRecordService;

@Service
public class StudentInterviewRecordServiceImpl implements StudentInterviewRecordService {

	@Autowired private StudentInterviewRecordDao recordDao;
	
	@Override
	public boolean insertRecord(StudentInterviewRecord record) {
		return this.recordDao.insertRecord(record);
	}

	@Override
	public boolean updateRecord(StudentInterviewRecord record) {
		return this.recordDao.updateRecord(record);
	}

	@Override
	public StudentInterviewRecord getRecordByKey(Long recorId) {
		StudentInterviewRecord record=null;
		StudentInterviewRecordExample example=new StudentInterviewRecordExample();
		Criteria criteria = example.createCriteria();
		criteria.andRecordIdEqualTo(recorId);
		List<StudentInterviewRecord> recordList = this.recordDao.getListByExample(example);
		if(!recordList.isEmpty()){
			record=recordList.get(0);
		}
		return record;
	}

	@Override
	public List<StudentInterviewRecord> getListByKeys(List<Long> idList) {
		StudentInterviewRecordExample example=new StudentInterviewRecordExample();
		Criteria criteria = example.createCriteria();
		criteria.andRecordIdIn(idList);
		return this.recordDao.getListByExample(example);
	}
	
	@Override
	public Map<String, Object> getRecordByMap(Map<String, Object> map) {
		Map<String, Object> recordMap=null;
		List<Map<String, Object>> mapList = this.recordDao.getListByMap(map);
		if(!mapList.isEmpty()){
			recordMap=mapList.get(0);
		}
		return recordMap;
	}

	@Override
	public List<StudentInterviewRecord> getRecordList() {
		StudentInterviewRecordExample example=new StudentInterviewRecordExample();
		return this.recordDao.getListByExample(example);
	}

	@Override
	public List<Map<String, Object>> getListByMap(Map<String, Object> map) {
		return this.recordDao.getListByMap(map);
	}

	@Override
	public boolean deleteByKeyList(List<Long> idList) {
		StudentInterviewRecordExample example=new StudentInterviewRecordExample();
		Criteria criteria = example.createCriteria();
		criteria.andRecordIdIn(idList);
		return this.recordDao.deleteByExample(example);
	}
}
